<template>
  <div id="closedloopcomp">
    <!-- Form-开始 -->
    <vxe-modal :title="`闭环展示`" width="55vw" height="55vh" resize v-model="dialogFormVisible" :mask="false" show-footer draggable>
      <template #default>
        <TimeLineCompV1 :items="closedLoopList" direction="horizontal" :isShowContent="false" />
      </template>
      <template #footer>
        <div class="flex justify-end">
          <el-button @click="closeDialog()">关闭</el-button>
        </div>
      </template>
    </vxe-modal>
    <!-- Form-结束 -->
  </div>
</template>
<script setup lang="ts">
import { ref, reactive, getCurrentInstance, watch, onMounted } from 'vue';
import { pageSizes, DateToString, formatDateTime, IsEmpty } from '@/utils/common';
import { VxeMessage, VxeNotifyType } from '@/utils/CommonMessage';
import { VXETable } from 'vxe-table';
import XEUtils from 'xe-utils';
import { AppStore } from '@/stores/store';
import axios from 'axios';
import TimeLineCompV1 from '@/components/TimeLineCompV1.vue';

// 全局变量定义区 ==========
let { proxy }: any = getCurrentInstance();
let store = AppStore();
let showLoading = ref(false);

let dialogFormVisible = ref(false);
let closedLoopList = reactive([]);
let props = defineProps({});
const pswInput = ref(null);//密码框el对象
defineExpose({
  initPage
})
onMounted(() => {
  //ToDo
});
/**接收父组件传过来的弹框展开状态
 * @param triggerSource 事件触发源【1：取消审核验证取消审核者、2：取消审核验证 检验者、3:微生物发布二级报告】 
 */
function initPage(row: any) {
  dialogFormVisible.value = true;
  // findLabReqMainClosedLoopInfo({ row });
  getTraceRecList({ row });
}

// 取消操作
function closeDialog() {
  dialogFormVisible.value = false;
}
/**加载闭环展示 */
function findLabReqMainClosedLoopInfo({ row }) {
  closedLoopList.length = 0;
  const url = '/lab/reqMain/findLabReqMainClosedLoopInfo';
  proxy.$http
    //注意此处的数据条数
    .get(url, {
      params: { reqNo: row.reqNo }
    })
    .then((res: any) => {
      res.data.forEach(e => {
        e.acter = '';
      });
      Object.assign(closedLoopList, res.data);
    })
    .catch((err: any) => {
      proxy.$alert('获取流程节点失败', '提示');
    });
}


// 获取跟踪记录
function getTraceRecList({ row }) {
  closedLoopList.length = 0;
  console.log('>>>>>>>>>>>>');
  const url = '/lab/mainState/getClosedLoopList';
  proxy.$http
    //注意此处的数据条数
    .get(url, {
      params: { reqNo: row.reqNo, isCloopShow: true }
    })
    .then((res: any) => {

      res.data.forEach(e => {
        const m = { title: e.stateName, timestamp: e.operateTime, acter: e.operator, content: e.remark };
        closedLoopList.push(m);
      });
    })
    .catch((err: any) => {
      proxy.$alert('获取流程节点失败', '提示');
    });
}

</script>
<style lang="scss" scope>
#pagepanelname {
  margin: 0;
}
</style>
